fix(intellij): read nx version under read action#3118
Conversation
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=lint,test,build,e2e-ci,ty... |
❌ Failed | 1m 5s | View ↗ |
nx-cloud record -- node tools/scripts/check-pin... |
✅ Succeeded | <1s | View ↗ |
nx-cloud record -- yarn nx sync:check |
✅ Succeeded | 11s | View ↗ |
nx-cloud record -- yarn nx run-many -t ktfmtFormat |
✅ Succeeded | 4m 59s | View ↗ |
nx run-many -t ktfmtFormat |
✅ Succeeded | 4m 53s | View ↗ |
nx-cloud record -- yarn nx format:check --verbose |
✅ Succeeded | <1s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-04-29 13:03:54 UTC
| return if (ApplicationManager.getApplication().isDispatchThread) { | ||
| nxVersion | ||
| } else { |
There was a problem hiding this comment.
Inconsistent behavior between dispatch and non-dispatch threads. When nxVersion is null on the dispatch thread, it returns null immediately without trying fallback methods. However, on non-dispatch threads, it attempts fallbacks via tryGetNxVersionFromNodeModules() and tryGetNxVersionFromPackageJson(). This creates unpredictable behavior where the same call returns different results depending on which thread it's called from.
If the dispatch thread case also needs to try fallbacks when nxVersion is null, it should wrap the fallback logic in ApplicationManager.getApplication().runReadAction<NxVersion?> or use invokeLater to avoid blocking the EDT:
return if (ApplicationManager.getApplication().isDispatchThread) {
nxVersion ?: ApplicationManager.getApplication().runReadAction<NxVersion?> {
tryGetNxVersionFromNodeModules() ?: tryGetNxVersionFromPackageJson()
}
} else {
nxVersion ?: ApplicationManager.getApplication().runReadAction<NxVersion?> {
tryGetNxVersionFromNodeModules() ?: tryGetNxVersionFromPackageJson()
}
}Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:
We investigated the CI failure and determined it is unrelated to this PR's changes. The build fails in Gradle's instrumentCode task due to a pre-existing implicit dependency on compileKotlin that Gradle 8.13 no longer permits, alongside a missing src/main/java directory that has never existed in this Kotlin-only project. The changed code compiled successfully (compileKotlin was UP-TO-DATE), confirming the fix itself is sound.
No code changes were suggested for this issue.
Trigger a rerun:
🎓 Learn more about Self-Healing CI on nx.dev

Wrap the synchronous Nx version fallback in an IntelliJ read action so background AI checks can parse package JSON PSI without threading assertions.